﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TB_CS.WeChat_Menu
{
    public partial class Menu_Manage : Form
    {
        public Menu_Manage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Class.SysInfo.WSEE.Update_Event(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID.ToString()),
                    textBox1.Text.Trim().ToString(),
                    textBox2.Text.Trim().ToString());
            textBox1.Text = "";
            textBox2.Text = "";
            dataGridView1.DataSource = Class.SysInfo.WSEE.GET_ALL_EVENT(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID)).Tables[0];
        }

        private void Menu_Manage_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = Class.SysInfo.WSEE.GET_ALL_EVENT(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID)).Tables[0];
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
            textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(textBox1.Text=="")
            {
                MessageBox.Show("请输入Event_Key", "警告");
            }
            else if(textBox2.Text == "")
            {
                MessageBox.Show("请输入Event_Value", "警告");
            }
            else
            {
                Class.SysInfo.WSEE.INSERT_EVENT(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID.ToString()),
                    textBox1.Text.Trim().ToString(),
                    textBox2.Text.Trim().ToString());
                textBox1.Text = "";
                textBox2.Text = "";
                dataGridView1.DataSource = Class.SysInfo.WSEE.GET_ALL_EVENT(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID)).Tables[0];
            }
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Class.SysInfo.WSEE.Delete_Event(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID.ToString()),
                    textBox1.Text.Trim().ToString());
            textBox1.Text = "";
            textBox2.Text = "";
            dataGridView1.DataSource = Class.SysInfo.WSEE.GET_ALL_EVENT(Convert.ToInt32(Class.SysInfo.INFO_Seller_ID)).Tables[0];
        }
    }
}
